<?php

/*
//need to account for future increases, i.e. no constants
//rewrite with foreach loops and put expansion values into an array
//function to calculate profession levels
//$var{$i}

	variables for function
	$name = profession name [input]
	$level = current character level [input]
	$skill = current profession skill [input]
	$expected = expected skill level [output]
	$colour = element colour [output]
	$capLevel = capped until [output]


1 - calculate the expected level from the profession and the level
2 - if the level is < expected return the appropriate colour
3 - (to do) return the level capped at

//at 50 expected = 250
//at 61 expected = 308
//at 70 expected = 375
at 80 expected = 450
at 85 expected = 525

	profession caps
75-150 (lvl 10)
150-225 (lvl 20)
225-300 (lvl 35)
300-375 (lvl 50)
375-450 (lvl 65)
450-525 (lvl 75)

gathering profession caps
75-150 (lvl 0)
150-225 (lvl 10)
225-300 (lvl 25)
300-375 (lvl 40)
375-450 (lvl 55)
450-525 (lvl 75)


first aid
225-300 (lvl 35)
300-375 (lvl 50)
375-450 (lvl 65)
450-525 (lvl 75)

archaeology
200-275 (lvl 35)
275-350 (lvl 50)
350-425 (lvl 60)
425-525 (lvl 75)
*/

function profTarget($name,$level,$skill)
{
	$exp0 = 5;//expected skill points per lvl without expansion
	$lvl0 = 60;
	$val0 = 300;
	$exp1 = 7.5;//expected skill points per lvl with 1st expansion etc.
	$lvl1 = 70;
	$val1 = 375;
	$exp2 = 7.5;
	$lvl2 = 80;
	$val2 = 450;
	$exp3 = 15;
	$lvl3 = 85;
	$val3 = 525;
	$exp4 = 15;//MOP content
	$lvl4 = 90;
	$val4 = 600;
	
	$max = 525;//change this when MOP is released

	//calculate expected value
	if ($name == 'Archaeology' && $level <20)
		{$expected = 0;}
	else if ($level <= $lvl0)
			{$expected = round($level * $exp0);}
	else if ($level <= $lvl1)
			{$expected = round((($level - $lvl0) * $exp1) + ($exp0 * $lvl0));}
	else if ($level <= $lvl2)
			{$expected = round((($level - $lvl1) * $exp2) + ($exp1 * ($lvl1-$lvl0)) + ($exp0 * $lvl0));}
	else//change this when MOP is released
		{$expected = (round($level-$lvl2) * $exp3) + ($exp2 * ($lvl2-$lvl1)) + ($exp1 * ($lvl1-$lvl0)) + ($exp0 * $lvl0);}
	
	//end expected calculation
	
	//now check to see if the character is at or below the expected skill level
	if ($skill >= $expected) //the character is either capped or green

	{
		if ($name == 'cooking'||$name =='fishing')//no caps on these profs
		{
			if ($skill>=$max)
				{$colour = 'warningCap';}//display in purple since you're at the max
			else
				{$colour = 'warningNone';}
		}//no caps so return green/purple

		else if ($name == 'archaeology') //slightly different caps
			{
				if ($level<35 && $skill>=200)
				{$colour = 'warningCap';$cap=35;}
				else if ($level<50 && $skill>=350)
				{$colour = 'warningCap';$cap=50;}
				else if ($level<60 && $skill>=425)
				{$colour = 'warningCap';$cap=60;}
				else if ($level<75 && $skill>=525)
				{$colour = 'warningCap';$cap=75;}
				else if ($level<85 && $skill>525)
				{$colour = 'warningCap';$cap=85;}
				else if ($skill>=$max)
				{$colour = 'warningCap';}
				else
				{$colour = 'warningNone';}
						
			}
		else if ($name == 'herbalism'||$name=='mining'||$name='skinning')
			{
				if ($level<10 && $skill>=150)
				{$colour = 'warningCap';$cap=10;}
				else if ($level<25 && $skill>=225)
				{$colour = 'warningCap';$cap=25;}
				else if ($level<40 && $skill>=300)
				{$colour = 'warningCap';$cap=40;}
				else if ($level<55 && $skill>=375)
				{$colour = 'warningCap';$cap=55;}
				else if ($level<75 && $skill>=450)
				{$colour = 'warningCap';$cap=75;}
				else if ($level<85 && $skill>=525)
				{$colour = 'warningCap';$cap=85;}
				else if ($skill>=$max)
				{$colour = 'warningCap';}
				else
				{$colour = 'warningNone';}//over the expected but not capped
			
			}
			
			//calculate other professions
		else if ($level<20 && $skill>=150 && $name <> 'first aid')//first aid not capped until lvl 35
				{$colour = 'warningCap';$cap=20;}				
		else if ($level<35 && $skill>=225)
				{$colour = 'warningCap';$cap=35;}
		else if ($level<50 && $skill>=300)
				{$colour = 'warningCap';$cap=50;}
		else if ($level<65 && $skill>=375)
				{$colour = 'warningCap';$cap=65;}
		else if ($level<75 && $skill>=450)
				{$colour = 'warningCap';$cap=75;}
		else if ($level<85 && $skill>=525)
				{$colour = 'warningCap';$cap=85;}
		else if ($skill>=$max)
				{$colour = 'warningCap';}
		else
			{$colour = 'warningNone';}//over the expected but not capped
	}

	else if ($skill < $expected) // cannot be capped
			{
			//return appropriate colour
			if ($expected<=$val0)
			{
				if (($expected-$skill)<(3*$exp0))//difference is less than 3 levels
					{$colour = 'warningMid';}
				else if (($expected-$skill)>=(3*$exp0))
						{$colour = 'warning';}
			}
			else if ($expected<=$val2 && $expected>$val0)
				{
					if (($expected-$skill)<(3*$exp2))//difference is less than 3 levels
						{$colour = 'warningMid';}
					else if (($expected-$skill)>=(3*$exp2))
							{$colour = 'warning';}
				}
			else if ($expected>$val2)
				{
					if (($expected-$skill)<(3*$exp3))//difference is less than 3 levels
						{$colour = 'warningMid';}
					else if (($expected-$skill)>=(3*$exp3))
							{$colour = 'warning';}
				}

		}


	return array ($expected, $colour, $cap);



}


?>
